﻿Imports System.Data.SqlClient

Public Class ketnoidulieu
    Private _connect As SqlConnection
    Public Property Connect() As SqlConnection
        Get
            Return _connect
        End Get
        Set(ByVal value As SqlConnection)
            _connect = value
        End Set
    End Property

    Private Function SQLConnect() As SqlConnection

        Dim Cn As New SqlConnection()
        Dim connect As String = "Server=.;Initial Catalog=THUE_NHA;Integrated Security=SSPI"
        Cn.ConnectionString = connect
        Return Cn

    End Function


    Public Sub New()
        Connect = New SqlConnection()
        Connect = SQLConnect()
    End Sub

    Public Function ExcuteDataTable(ByVal sql As String) As DataTable

        Dim da As New SqlDataAdapter(sql, Connect)
        Dim dt As New DataTable()
        da.Fill(dt)
        Connect.Close()
        Return dt

    End Function

    Public Sub SQL_ExecuteNonQuery(ByVal sql As String)
        Dim cmd As New SqlCommand(sql, Connect)
        Try
            cmd.Connection.Open()
            cmd.ExecuteNonQuery()
            cmd.Connection.Close()
        Catch
        End Try
    End Sub
End Class
